import { _decorator, Component, EditBox, Label, Layout, Node, ScrollView, Slider, Sprite, Toggle, Vec2, Vec3 } from 'cc';
import { UIManager } from '../UIManager';
import { LanauageManager } from '../LanauageManager';
import { GameData } from '../GameData';
import { HttpClient } from '../net/HttpClient';
import { EventManager } from '../EventManager';
import { AudioMgr } from '../AudioMgr';
import { Util } from '../Util';
const { ccclass, property } = _decorator;

@ccclass('popupComonTip')
export class popupComonTip extends Component {


    @property(Label)
    titleLab:Label = null;

    @property(Node)
    tipNode:Node = null;

    @property(Label)
    tipDesLab:Label = null;

    /**0 通用提示，1修改名称，2智能管家 */
    statu:number; 

    /** 0 是否确定签名 */
    type:number = 0;

    sign:string = "";
    
    onEnable() {
        
        this.statu = UIManager.openData.statu;

        this.type = UIManager.openData.type;

        this.sign = UIManager.openData.sign;

        this.refresh();
    }

    refresh(){

    }

    onClickHandler(event:Event, str:string){
        if (str == "tipScalBtn"){
            this.closeView();
        }
        else if (str == "tipSureBtn"){
            if (this.sign == ""){
                UIManager.showTip("简介不能为空");
                return;
            }
            HttpClient.getInstance().sendChangeName(GameData.getIns().userData.nickname, this.sign, GameData.getIns().userData.avatar, ()=>{
                this.closeView();
            });
        }
    }

    closeView(){
        UIManager.close(this.node);
    }
}

